<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<h:outputStylesheet name="layout.css" library="css" />
	<h:outputScript name="script.js" library="js" />
	<title>#{msg.tituloPaginaPricipal}</title>
</h:head>
<h:body>
	
	<f:view contentType="text/html">
		<p:dialog header="#{msg.tituloTelaLogin}" visible="true"
			closable="false" draggable="false" resizable="false" width="600">
			<h:form>

				<h:panelGrid columns="3" cellpadding="5"
					rendered="#{not loginMB.selecionarEmpresa}">
					<h:outputLabel value="Usuário: " />
					<p:inputText required="true" id="usuarioAcesso" label="Usuário"
						value="#{loginMB.username}" />
					<p:message for="usuarioAcesso" showDetail="true" showSummary="true" />

					<h:outputLabel value="Senha: " />
					<p:password required="true" id="senhaAcesso" label="Senha"
						value="#{loginMB.password}" feedback="false" />
					<p:message for="senhaAcesso" showDetail="true" showSummary="true" />

					<p:commandButton value="Entrar" action="#{loginMB.login}"
						update="@form" />
				</h:panelGrid>


				<p:dataTable value="#{loginMB.empresas}" var="empresa"
					rendered="#{loginMB.selecionarEmpresa}">
					<f:facet name="header">
						<h:outputText value="Clínicas Disponíveis para o Usuário" />
					</f:facet>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Razão Social" />
						</f:facet>
						<h:outputText value="#{empresa.razaoSocial}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Nome Fantasia" />
						</f:facet>
						<h:outputText value="#{empresa.nomeFantasia}" />
					</p:column>

					<p:column style="width:32px">
						<p:commandLink action="#{loginMB.autenticar(empresa)}"
							update="@form">
							<p:graphicImage value="#{resource['images/edit.png']}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>

				<p:growl globalOnly="true" showDetail="true" showSummary="true" />
			</h:form>
		</p:dialog>

	</f:view>
</h:body>
</html>
